//
//  FileWriter.h
//  ImageReplacer
//
//  Created by Tyler Powell on 4/30/12.
//  Copyright 2012 Georgia Institute of Technology. All rights reserved.
//

#import <Cocoa/Cocoa.h>


@interface FileWriter : NSObject <NSConnectionDelegate>{
    NSMutableArray* images;
    NSMutableArray* enbuttons;
    NSMutableArray* disbuttons;
    NSMutableArray* options;
    NSMutableArray* launchers;
    
    NSString* imagesPath;
    NSString* enbuttonsPath;
    NSString* disbuttonsPath;
    NSString* optionsPath;
    NSString* launchersPath;
}
@property (copy) NSMutableArray* images;
@property (copy) NSMutableArray* enbuttons;
@property (copy) NSMutableArray* disbuttons;
@property (copy) NSMutableArray* options;
@property (copy) NSMutableArray* launchers;

BOOL writeiLoLFile(NSString* fileName, NSString* write);
BOOL writeFile(NSString* fileName, NSString* write);
BOOL createFile(NSString* fileName);
int countLines(NSString* fileName);
BOOL replacePatcherImage(NSString* fileName, BOOL random);
BOOL replaceFile(NSString* fileName, NSString* fileToReplace, int index);
NSArray* getImageFiles(NSString* fileName);
NSArray* getLines(NSString* fileName);
NSString* linesToString(NSArray* lines);
NSString* linesToStringWithEmptyStrings(NSArray* lines);
BOOL fileContains(NSString* fileName, NSString* itemName);
BOOL removeItemFromFile(NSString* fileName, int index);
NSString* getItemFromFileAtIndex(NSString* fileName, int index);
void writeToFileAtIndex(NSString* fileName, NSString* line, int index);
void initializeOptions();

//hopefully this will replace all above
-(void) addImage:(NSString*)filePath;
-(void) addEnabledButton:(NSString*)filePath;
-(void) addDisabledButton:(NSString*)filePath;
-(void) addLauncher:(NSString*)filePath;
-(void) removeImage:(NSInteger)index;
-(void) removeEnabledButton:(NSInteger)index;
-(void) removeDisabledButton:(NSInteger)index;
-(void) removeLauncher:(NSInteger)index;
-(void) replaceImageAtIndex:(NSInteger)index withImage:(NSString*) newImage;
-(void) replaceEnabledButtonAtIndex:(NSInteger)index withImage:(NSString*) newImage;
-(void) replaceDisabledButtonAtIndex:(NSInteger)index withImage:(NSString*) newImage;
-(void) replaceOptionAtIndex:(NSInteger)index withOption:(id) newOption;
-(void) replaceLauncherAtIndex:(NSInteger)index withImage:(NSString*) newImage;
-(void) saveImages;
-(void) saveEnabledButtons;
-(void) saveDisabledButtons;
-(void) saveOptions;
-(void) saveLaunchers;
-(BOOL) needsUpdate;
-(void) updateApp;
-(void) replaceFiles:(BOOL)checkBoxState;
+(void) serializeObjectToFile:(NSString*) filePath objectToWrite:(id) object;
+(void) serializeArrayToFile:(NSString*) filename array:(NSArray*) array;
+(id) deserializeObjectFromFile:(NSString*) filePath;
+(id) deserializeArrayFromFile:(NSString*) filename;

@end
